home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / MSGlobal.inc < prev    next >
Encoding:
Text File  |  1998-11-20  |  22.5 KB  |  733 lines

  1. <SCRIPT RUNAT=SERVER LANGUAGE=VBSCRIPT>
  2.  
  3. '////////////////////////////////////////////////////////////////////
  4. '//                                                                //
  5. '//   NetObjects Fusion ASP Components                             //
  6. '//   Custom JScript Library Functions                             // 
  7. '//                                                                //
  8. '////////////////////////////////////////////////////////////////////
  9. '/*
  10. 'Version:      1.0  9/23/97
  11. '
  12. 'Written By:   Application Methods, Inc.
  13. '              6300 Southcenter Blvd.
  14. '              Seattle, WA 98188
  15. '              (206) 244-2400
  16. '              http://www.appmethods.com
  17. '
  18. 'DESCRIPTION: This file contains a variety of functions common to various
  19. 'Fusion database components. 
  20. '
  21. '=====================================================================*/
  22.  
  23. ' Formats a date object into a string of the form mm-dd-yyyy
  24. '
  25. function formatDate( MyDate ) 
  26.  
  27.    DATEDELIM = "-"
  28.    returnVal = ""
  29.    
  30.    if ((not isnull(myDate)) and (myDate <> "")) then
  31.       ' Put in format mm-dd-yyyy
  32.  
  33.       if len(Month(myDate)) = 1 then 
  34.         monthPad = "0"
  35.       else
  36.         monthPad = ""
  37.       end if
  38.       if len(Day(myDate)) = 1  then 
  39.         dayPad = "0"
  40.       else
  41.         dayPad = ""
  42.       end if
  43.       
  44.       returnVal = monthPad & Month(myDate) & DATEDELIM & dayPad & Day(myDate) & DATEDELIM & Year(myDate)
  45.    end if
  46.   
  47.    formatDate = returnVal
  48.  
  49. end function ' END function formatDate
  50. </SCRIPT>
  51.  
  52.  
  53. <SCRIPT RUNAT=SERVER LANGUAGE=JSCRIPT>
  54. function write(txt)
  55. {
  56.     // Write the string out to the browser as html
  57.     Response.Write(txt);
  58. }    //End write
  59.  
  60. function debug(txt)
  61. {
  62.     // Write the string out to the browser as html - include an indication that this is a debug statement
  63.     var pre = "DEBUG: ";
  64.     Response.Write(pre + txt + "<br>\n");
  65. }    //End write
  66.  
  67.  
  68.  
  69. // 
  70. // Wrap an argument it the proper SQL delimiters based on it's data type and the database type
  71. //
  72. function wrapDelim(databaseType, dataType, fieldValue) {
  73.    
  74.    var returnVal = "";
  75.    var datestr;
  76.    
  77.    // Check for null parameter values
  78.    databaseType = (databaseType == null) ? "" : databaseType;
  79.    
  80.    // Temp Removed for good reason but kept for safe keeping
  81.    //ODBCDatabaseType = (ODBCDatabaseType == null) ? "" : ODBCDatabaseType;
  82.    //if (Application("databaseType") != null) {
  83.    //      databaseType = Application("databaseType");   
  84.    //}
  85.    
  86.    // Convert to all upper case for uniform comparisons   
  87.    databaseType = databaseType.toUpperCase();
  88.    dataType = dataType.toLowerCase();
  89.       
  90.    if (fieldValue != null) {   
  91.     // Strings
  92.       if (dataType == "string"){
  93.          returnVal = "'"+fixSingleQuotes(fieldValue)+"'";
  94.       } // Numbers
  95.       else if (dataType == "number" || dataType == "boolean"){
  96.          returnVal = fieldValue;
  97.       } // Dates
  98.       else if (dataType == "date") {
  99.          if (databaseType == "ODBC") {
  100.                datestr = convertDate(databaseType, fieldValue);
  101.                if ((datestr == "") || (datestr == null))
  102.                   returnVal = null;
  103.                else
  104.                   returnVal = "{d '"+convertDate(databaseType, fieldValue)+"'}";
  105.          } // end ODBC if
  106.          else {
  107.                datestr = convertDate(databaseType, fieldValue);
  108.                if ((datestr == "") || (datestr == null))
  109.                   returnVal = null;
  110.                else 
  111.                    returnVal = "'"+datestr+"'";         
  112.          }
  113.       } // end Date if
  114.       else returnVal = "'"+fieldValue+"'";
  115.    } // end fieldValue if
  116.    else {
  117.       returnVal = "";
  118.    }
  119.    
  120.    return returnVal;
  121.    
  122. } // END function wrapDelim
  123.  
  124.  
  125. //
  126. // Convert JavaScript date string literal to a date string literal acceptable to the database
  127. //
  128. /* 
  129.  DESCRIPTION:
  130.  Reads in representation of a Date object as a string,
  131.  e.g. "Mon Jan 23 03:30:15 1994", and converts it to a string 
  132.  literal format for a date literal demanded by a specified database type. 
  133.  
  134.  NOTE:  This function assumes the default date format for each database type is used.
  135.  If this format is changed by the DBA or system administrator, this function may
  136.  fail to format dates properly in the SQL statement.
  137. */
  138. function convertDate(databaseType, myDateStr) {
  139.  
  140.       var myDate = new Object();
  141.       var returnVal = "";
  142.       
  143.       // Undo formatting of date string and place date in new date object
  144.       myDate = undoFormatDate(myDateStr);
  145.       
  146.       if (myDate != null) {
  147.          // Get date pieces for database specific formatting
  148.          fmonth = ((myDate.getMonth() + 1) + "").length == 1 ? "0" + (myDate.getMonth() + 1) : myDate.getMonth() + 1;
  149.          fmonthString = getMonthStr(fmonth);
  150.          fdate = (myDate.getDate() + "").length == 1 ? "0" + myDate.getDate() : myDate.getDate();
  151.          fyear = myDate.getYear() + 1900;
  152.       
  153.          // Create a new date string literal depending on the database type
  154.          if (databaseType.toUpperCase() == "INFORMIX")   
  155.             returnVal = fmonth + "/" + fdate + "/" + fyear;    // mm/dd/yyyy
  156.          else if (databaseType.toUpperCase() == "ORACLE")
  157.             returnVal = fmonthString + " " + fdate + ", " + fyear;   // mmm dd, yyyy
  158.          else if (databaseType.toUpperCase() == "ODBC")
  159.             returnVal = fyear+"-"+fmonth+"-"+fdate;     // yyyy-mm-dd
  160.          else
  161.             returnVal = fyear+"-"+fmonth+"-"+fdate;  // ANSI SQL standard format, yyyy-mm-dd
  162.       }
  163.  
  164.       return returnVal;
  165. } // END function convertDate
  166.  
  167.  
  168. //
  169. // Parses out a date string in the format mm-dd-yyyy into a date object
  170. //
  171. function undoFormatDate ( dateStr ) {
  172.    
  173.    var month = date = year = 0;
  174.    var tempStr = "";
  175.    var theDate = null;   
  176.  
  177.    if ((dateStr != null) && (dateStr != "")) {
  178.  
  179.       // initialize counter   
  180.       var count = 1;
  181.       // The loop cycles through the date string.  It builds up numbers in tempStr until
  182.       // it finds a character in dateStr.  At that time it parses tempStr into a numeric
  183.       // value and depending on it's position in the string (determined by "count") it
  184.       // is assigned to the month, date or year.   
  185.       for (var j=0; j <= dateStr.length; j++) {
  186.          // Short-circuit evaluation
  187.          if ((j != dateStr.length) && (IsNum(dateStr.charAt(j)))) {
  188.             tempStr += dateStr.charAt(j);
  189.          }   
  190.          else {
  191.             if (count == 1) {
  192.                // If count == 1, we're at the first set of numbers ==> the month in mm-dd-yyyy
  193.                month = parseInt(tempStr, 10) - 1;  // subtract 1 to adjust for what Date constructor needs
  194.                tempStr = "";
  195.                count++;
  196.             } else if (count == 2) {
  197.                // If count == 2, we're at the first set of numbers ==> the date in mm-dd-yyyy
  198.                date = parseInt(tempStr, 10);
  199.                tempStr = "";
  200.                count++;
  201.             } else if (count == 3) {
  202.                // If count == 3, we're at the first set of numbers ==> the year in mm-dd-yyyy
  203.                year = parseInt(tempStr, 10);
  204.                // Fix for one of JavaScript's Date bugs - if year >= 2000, must feed in 
  205.                // year - 1900, not just the year as you can do with years < 2000.
  206.                // Note: this bug is not relavant in JScript
  207.                //if (year >= 2000)
  208.                   //year = year - 1900;
  209.                tempStr = "";
  210.                count++;
  211.             } // end if
  212.             
  213.          } // end else
  214.       } // end for
  215.  
  216.    // Create date object with parsed values
  217.    theDate = new Date(year, month, date);
  218.  
  219.    }   // end if
  220.    
  221.    return theDate;
  222. } // END undoFormatDate
  223.  
  224.  
  225. //
  226. // Formats a value before it's added to a URL.
  227. // Also handles any special formatting for certain data types, e.g. dates
  228. // 
  229. function formatDataValue (value, dataType) {
  230.  
  231.    var formattedVal = value;
  232.    
  233.    // Handle special cases for certain data types.
  234.    // Dates will always be formatted according to the "formatDate()" function
  235.    // No other data types require special handling at this time.
  236.    if (dataType.toUpperCase() == "DATE") {
  237.       formattedVal = formatDate(value);
  238.    }
  239.  
  240.    return formattedVal;
  241. }  // END formatDataValue
  242.  
  243.  
  244. //
  245. // Translate numeric month representation into 3-character month string
  246. //
  247. function getMonthStr(month) 
  248. {
  249.    var returnVal = "";
  250.    
  251.    // Check for null and exit if true
  252.    if (month == null)
  253.       return "";
  254.    
  255.    if (month == 1){
  256.       returnVal = "Jan"
  257.    } 
  258.    else if (month == 2){
  259.       returnVal = "Feb"
  260.    } 
  261.    else if (month == 3){
  262.       returnVal = "Mar"
  263.    } 
  264.    else if (month == 4){
  265.       returnVal = "Apr"
  266.    } 
  267.    else if (month == 5){
  268.       returnVal = "May"
  269.    } 
  270.    else if (month == 6){
  271.       returnVal = "Jun"
  272.    } 
  273.    else if (month == 7){
  274.       returnVal = "Jul"
  275.    } 
  276.    else if (month == 8){
  277.       returnVal = "Aug"
  278.    } 
  279.    else if (month == 9){
  280.       returnVal = "Sep"
  281.    } 
  282.    else if (month == 10){
  283.       returnVal = "Oct"
  284.    } 
  285.    else if (month == 11){
  286.       returnVal = "Nov"
  287.    } 
  288.    else if (month == 12){
  289.       returnVal = "Dec"
  290.    } 
  291.    else returnVal = "";
  292.    
  293.    return returnVal;
  294. } // END function getMonthStr
  295.  
  296.  
  297.  
  298. //////////////////////////////////
  299. //                              //
  300. //     Validation Functions     // 
  301. //                              //
  302. //////////////////////////////////
  303.  
  304. //
  305. // Functions for testing the validity of various strings and numeric values
  306. //
  307.  
  308.  
  309. /*=============================================================
  310.  
  311. FUNCTION:     IsAlpha
  312.  
  313. PURPOSE:     Determines if a given string contains only alphabetic characters.
  314.  
  315. INPUT:      str (string) - the string to be tested
  316.  
  317. RETURNS:     (Boolean) - true, if the string contains only alphabetic characters (of any case)
  318.       false, otherwise.
  319.  
  320. DESCRIPTION:   This function simply looks through a string to see if it contains only alphabetic
  321.       characters, of upper or lower case.  
  322.  
  323.   =============================================================*/
  324.  
  325. function IsAlpha( str )
  326. {
  327.    var isValid = true;
  328.  
  329.    str += "";   // convert to a string for performing string comparisons.
  330.  
  331.    // Loop through string one character at time,  breaking out of for
  332.    // loop when an non Alpha character is found.
  333.  
  334.       for (i = 0; i < str.length; i++)
  335.       {
  336.       // Alpha must be between "A"-"Z", or "a"-"z"
  337.       if ( !( ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
  338.                ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ) )
  339.                {
  340.                      isValid = false;
  341.                      break;
  342.                }
  343.       } // END for   
  344.    
  345.    return isValid;
  346.  
  347. }  // END FUNCTION IsAlpha 
  348.  
  349.  
  350.  
  351. /* ===================================================
  352. FUNCTION:   IsAlphaNum
  353.  
  354.  INPUT:      numstr - a string that will be tested to ensure that
  355.                each character is a digit or a letter.
  356.  
  357.  RETURN:        true, if all characters in the string are a character from 0-9
  358.               or a-z otherwise the function returns false
  359.  
  360.  NOTE:          This function is used to test strings only.  Inputting
  361.          a numeric or boolean variable will give unpredictable results.
  362.  
  363. =================================================== */
  364.  
  365. function IsAlphaNum( str )
  366. {
  367.    var i = 0;
  368.    var isValid = false;
  369.    
  370.    // convert to a string for performing string comparisons.
  371.       str += "";   
  372.  
  373.    
  374.    // Loop through length of string and test for any alpha numeric 
  375.    // characters
  376.       for (i = 0; i < str.length; i++)
  377.       {
  378.       // Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
  379.             if ( ((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
  380.                ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
  381.                ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) )
  382.                   isValid = true;
  383.       } // END for   
  384.    
  385.       return isValid;
  386.  
  387. }  // END FUNCTION IsAlphaNum
  388.  
  389.  
  390.  
  391. /*=============================================================
  392.  
  393. FUNCTION:   IsAlphaNumOrUnderscore
  394.  
  395. PURPOSE:     Determines if a given string contains only alphanumeric characters or underscores.
  396.  
  397. INPUT:      str (string) - the string to be tested
  398.  
  399. RETURNS:     (Boolean) - true, if the string contains only alphanumeric characters or underscores.
  400.       false, otherwise.
  401.  
  402. DESCRIPTION:   This function simply looks through a string to see if it contains only alphanumeric
  403.       characters or underscore characters.  
  404.  
  405. =============================================================*/
  406.  
  407. function IsAlphaNumOrUnderscore( str )
  408. {
  409.  
  410.    var i = 0;
  411.    var isValid = true;
  412.  
  413.     str += "";   // convert to a string for performing string comparisons.
  414.  
  415.    // Loop through string one character at a time. If non-alpha numeric
  416.    // is found then, break out of loop and return a false result
  417.  
  418.    for (i = 0; i < str.length; i++)
  419.       {
  420.       // Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
  421.             if ( !( ((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
  422.                ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
  423.                ((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ||
  424.                (str.charAt(i) == "_") ) )
  425.                {
  426.                isValid = false;
  427.                      break;
  428.                }
  429.  
  430.    } // END for   
  431.    
  432.    return isValid;
  433.  
  434. }  // END FUNCTION IsAlphaNumOrUnderscore
  435.  
  436.  
  437.  
  438. /* ===================================================
  439. FUNCTION:   IsBlank
  440.  
  441. INPUT:      teststr - the string to be tested
  442.  
  443. RETURN:        true, if the string is null or is an empty string, ""
  444.             false, otherwise.
  445.  
  446. NOTE:          This function is used to test strings only.  Entering
  447.         a numeric or Boolean variable will give unpredictable results.
  448.  
  449. =================================================== */
  450.  
  451. function IsBlank( teststring )
  452. {
  453.    var result = false;
  454.  
  455.     if ( (teststring == null) || (teststring == "") )
  456.       result = true;
  457.  
  458.    return result;
  459.  
  460. }  // END FUNCTION IsBlank
  461.  
  462.  
  463.  
  464. /* ===================================================
  465. FUNCTION:     IsNum
  466.  
  467. INPUT:        numstr - a string that will be tested to ensure that
  468.             each character is a digit
  469.  
  470. RETURN:        true, if all characters in the string are a character from 0-9
  471.            false, otherwise.
  472.  
  473. NOTE:          This function is used to test strings only.  Inputting
  474.          a numeric or boolean variable will give unpredictable results.
  475. =================================================== */
  476.  
  477. function IsNum( numstr )
  478. {
  479.    var IsValid = true;
  480.  
  481.    // convert to a string for performing string comparisons.
  482.    numstr += "";   
  483.  
  484.    // Loop through string and test each character. If any
  485.    // character is not a number, return a false result.
  486.    
  487.    for (i = 0; i < numstr.length; i++)
  488.      {
  489.        if (! ((numstr.charAt(i) >= "0") && 
  490.              (numstr.charAt(i) <= "9")) ) {
  491.           IsValid = false;
  492.           break;
  493.       }
  494.                                
  495.    } // END for   
  496.    
  497.       return IsValid;
  498.  
  499. }  // END FUNCTION IsNum
  500.  
  501.  
  502.  
  503. //////////////////////////////////////////////////
  504. //                                              //
  505. //            Cursor Count Functions            //
  506. //                                              //
  507. //////////////////////////////////////////////////
  508.  
  509. /*      The following two functions are used to determine when to close cursors and possibly 
  510. * database connections on a page.  Cursors and connections must be closed at the end
  511. * of use for ASP 3.0.
  512. *     The functions will increment or decrement a counter value that only exists per Session.
  513. * The counter will be incremented in all of the constructors for objects that use cursors,
  514. * and will be decremented in the render methods of the same objects.  Each render method will
  515. * check the value after decrementing to see if it has reached zero.  If so, that means all 
  516. * cursor-using components on the page have fired and the cursor may now be safely closed. 
  517. */
  518.  
  519.  
  520. //
  521. //  incCursorCallCount increments the global page cursor usage counter
  522. //
  523. function incCursorCallCount() {
  524.  
  525.    // If not called for first time, increment
  526.    if ((Session("amaspHidden_CursorCallCount") != null) && (Session("amaspHidden_CursorCallCount") != "undefined"))
  527.       Session("amaspHidden_CursorCallCount") = (parseInt(Session("amaspHidden_CursorCallCount"), 10) + 1) + "";
  528.    else
  529.       Session("amaspHidden_CursorCallCount") = 1 + "";   // if called for the first time, init. to 1
  530.       
  531.       return parseInt(Session("amaspHidden_CursorCallCount"), 10);
  532.  
  533. } // END incCursorCallCount
  534.  
  535.  
  536. //
  537. //  decCursorCallCount decrements the global page cursor usage counter
  538. //
  539. function decCursorCallCount(queryComponentName) {
  540.  
  541.     var callCount;
  542.    Session("amaspHidden_CursorCallCount") = (parseInt(Session("amaspHidden_CursorCallCount"), 10) - 1) + "";
  543.     
  544.     callCount = parseInt(Session("amaspHidden_CursorCallCount"), 10);
  545.     
  546.     // If we've reached the bottom component, close it's cursor component.
  547.     if (callCount == 0) {
  548.         eval(queryComponentName + ".closeCursor()");
  549.         // Also, if not using a global connection, disconnect from DB
  550.         if (Application("globalConn") != "true");
  551.             //Temp close connection;
  552.     } // end outer if
  553.  
  554.    return 
  555.  
  556. } // END decCursorCallCount
  557.  
  558.  
  559.  
  560. //////////////////////////////////////////////////
  561. //                                              //
  562. //     Custom JavaScript Object:  NewRequest    // 
  563. //                                              //
  564. //////////////////////////////////////////////////
  565.  
  566. function NewRequest () {
  567.  
  568.    // Constant Properties
  569.    
  570.    // All properties passed via the request object which
  571.    // are generated by these components contain this special
  572.    // prefix in their property name.  
  573.    this.UNIQUEPREFIX = "amasp";  
  574.    
  575.    // Properties that indicate a field name, such as from a DBDynaField or a keyfield from a DBList,
  576.    // contain this prefix.  This allows the NewRequest object to strip off the prefix so the DBQuery
  577.    // object knows what fields to add to it's 'where' clause.
  578.    this.FIELDPREFIX = this.UNIQUEPREFIX + "Field_";
  579.  
  580.    // Properties
  581.    this.oldRequest = new Object();
  582.    this.newRequest = new Object();
  583.  
  584.    // Methods   
  585.     this.parseOldRequest = nrParseOldRequest;
  586.    this.smartClone = nrSmartClone;
  587.  
  588.     // Initialize object:
  589.  
  590. // JJK Bug Fix, 980603 BEGIN
  591.     var rform = "";
  592.     var rqstring = "";    
  593.  
  594.     // Make sure no undefined value exist.  If they do, just set to empty string.
  595.     if (Request.Form+"" != "undefined")
  596.         rform = Request.Form+"";
  597.     if (Request.QueryString+"" != "undefined")
  598.         rqstring = Request.QueryString+"";
  599.  
  600.     // Parse out values from request and put in oldRequest property
  601.     this.parseOldRequest(rform + rqstring, 0);
  602. // JJK, 980603 END
  603.  
  604.     // Clone old Request object and use intelligent processing to strip out unwanted values
  605.     this.newRequest = this.smartClone( this.oldRequest );
  606.  
  607. }  // END NewRequest constructor
  608.  
  609.  
  610. function nrParseOldRequest ( mystr, lastIndex ) {
  611.  
  612.     var ampIdx = 0;    // index of the right-most '&' char in the string
  613. //    var rObj = new Object();  // initialize variable as a blank object
  614.     
  615.     ampIdx = mystr.indexOf("&", lastIndex);
  616.  
  617.     // Loop recursively until we reach the end of the string (signified by no-more &'s)
  618.     if (ampIdx != -1)
  619.         this.parseOldRequest(mystr, ampIdx + 1 );
  620.     
  621.     // Strip off any unprocessed name=value pairs on the left side of the string
  622.     mystr = mystr.substring(lastIndex, mystr.length);
  623.  
  624.     // Find the divider between the name and the value
  625.     tHalfIdx = mystr.indexOf("=");
  626.     // Find the end of the left-most name=value pair
  627.     tEndIdx = mystr.indexOf("&") != -1 ? mystr.indexOf("&") : mystr.length;
  628.  
  629.     // Store name=value pair as object.name=URLDecode(value) i.e. URLDecode value first.
  630.     this.oldRequest[mystr.substring(0, tHalfIdx)] = URLDecode(mystr.substring(tHalfIdx+1, tEndIdx));
  631.     
  632. }  // END nrParseOldRequest
  633.  
  634.  
  635. //
  636. //  Clone only the properties of the request object that are not default properties (e.g. request.ip)
  637. //  This does allow for a custom user-defined property that has the same name as a default property, however.
  638. //
  639. function nrSmartClone ( obj ) {
  640.  
  641.    var temp = "";
  642.    var flength = 0;
  643.    var plength = 0;
  644.  
  645.    // Assign length to a variable.  Workaround for JScript bug and substring function.
  646.    // substring will not accept "mystring.length" for both of it's length fields.  Always 
  647.    // returns an empty string.   
  648.    flength += this.FIELDPREFIX.length;
  649.  
  650.    // Loop through request object and add only properties prefixed with this.UNIQUEPREFIX 
  651.    // into the new request object to ensure no built-in LiveWire properties are included
  652.    // with the new request object properties.
  653.    for (var prop in obj) {
  654.       temp = prop + "";
  655.  
  656.       if (prop.indexOf(this.UNIQUEPREFIX) != -1) {
  657.          if (prop.indexOf(this.FIELDPREFIX) != -1) {
  658.             // Workaround for JScript bug in substring function
  659.             plength = prop.length;      
  660.             // Strip off the prefix indicated by this.FIELDPREFIX
  661.             temp = prop.substring(flength, plength);
  662.          }
  663.          // Create and populate the properties of the newRequest object
  664.          this.newRequest[temp] = obj[prop];
  665.  
  666.       }
  667.  
  668.    } // end for
  669.             
  670.    return this.newRequest;
  671.    
  672. }  // END nrSmartClone
  673.  
  674.  
  675. //
  676. // Remove any plus signs that are introduced as part of URL encoding
  677. // Then unescape the string and return it.
  678. //
  679. function URLDecode ( mystr ) {
  680.  
  681.     var newstr = "";
  682.     
  683.     // Loop through each char in string.
  684.     // If it's a +, replace with a space in the new string
  685.     // else, just insert the same character as in mystr
  686.     for (var i = 0; i < mystr.length; i++) {
  687.         if (mystr.charAt(i) == "+")
  688.             newstr += " ";
  689.         else
  690.             newstr += mystr.charAt(i);
  691.     }
  692.     
  693.     return unescape(newstr);
  694.  
  695. }  // END URLDecode
  696.  
  697.  
  698. // 
  699. // Convert empty strings to nulls for input of specific data types
  700. //
  701. function convertForInput(dataType, fieldValue) {
  702.   
  703.    if ((dataType == "number" || dataType == "boolean" || dataType == "date") && (fieldValue == null || fieldValue == "null" || fieldValue == "")) { 
  704.        return null;
  705.    }
  706.    else {
  707.       return fieldValue;
  708.    }
  709.  
  710. }  // end convertForInput
  711.  
  712. function viewObject (obj,objName) {
  713.  
  714.   write("\n<BR><B>"+objName+" Properties: </B><HR>");
  715.   for (prop in obj) {
  716.       write("\n<BR>"+objName+"."+prop+" = "+obj[prop]);
  717.   }
  718.   write("\n<BR><HR><BR>");
  719. }
  720.  
  721. function fixSingleQuotes(inputstring) {
  722. // fixSingleQuotes("'Test1Tes't1Test1''Test1'")
  723.   var newstring = "";
  724.  
  725.   for (var i = 0; i < inputstring.length; i++) {
  726.     newstring +=  (inputstring.charAt(i) == "'") ? inputstring.charAt(i) +"'" : inputstring.charAt(i) +"";
  727.   }
  728.  
  729.   return newstring;
  730. }
  731.  
  732. </SCRIPT>